<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="/css/bootstrap.css" rel="stylesheet">
</head>
<body>
<div th:include="~{main/index :: nav}"></div>
<h2>用户管理</h2>
<hr>
<div style="display: flex;justify-content: space-evenly;">
    <div style="width: 67%;">
        <table class="table table-hover table-striped table-bordered" border="1" width="95%" style="text-align: center">
            <tbody>
            <tr style="background-color: gainsboro">
                <th>编号</th>
                <th>姓名</th>
                <th>手机号</th>
                <th>头像</th>
                <th th:if="${action eq 'stu'}">班级编号</th>
                <th th:if="${action eq 'stu'}">班级名称</th>
                <th>修改用户</th>
                <th>删除用户</th>
            </tr>
            <tr th:each="us:${users}">

                <td><span th:text="${us.uid}"></span></td>
                <td><span th:text="${us.uname}"></span></td>
                <td><span th:text="${us.phone}"></span></td>
                <!--<td><span th:text="${t.pwd}"></span></td>-->
                <td style="width: 6vw;height: 6vw">
                    <img th:src="'/adm/'+${action}+'/showimg/'+${us.pic}" style="width: 100%;height: 100%">
                </td>
                <span th:if="${action eq 'stu'}">
                    <td><span th:text="${us.clz.clzno}"></span></td>
                    <td><span th:text="${us.clz.clzname}"></span></td>
                </span>

                <td>
                    <a th:href="'/adm/'+${action}+'/go2Update?uid='+ ${us.uid} + '&curPage='+ ${curPage}"><button class="btn btn-warning">更改</button></a>
                </td>
                <td>
                    <a th:href="'/adm/'+${action}+'/del?uid='+ ${us.uid} + '&curPage='+ ${curPage}"><button class="btn btn-warning">删除</button></a>
                </td>
            </tr>
            </tbody>
        </table>

        <p style="text-align: center">
            <a th:if="${curPage-1} ge 1"  th:href="@{'/adm/'+${action}+'/prevPage?curPage='+ ${curPage-1}}">上一页</a>
            <a th:if="${curPage-1} lt 1"  th:href="@{'/adm/'+${action}+'/prevPage?curPage=1'}">上一页</a>
            <span th:text="${curPage} +'/'+${totalPage}"/>
            <a th:if="${curPage+1} le ${totalPage}" th:href="@{'/adm/'+${action}+'/nextPage?curPage='+ ${curPage+1}}">下一页</a>
            <a th:if="${curPage+1} gt ${totalPage}"  th:href="@{'/adm/'+${action}+'/nextPage?curPage=' + ${totalPage}}">下一页</a>
        </p>

    </div>
    <!-- 输入-->
    <div style="width: 30%;">

        <div th:if="${date == null}">
            <button class="btn btn-warning">
                <a th:if="${action eq 'stu'}" th:href="'/adm/'+${action}+'/go2Add/'+ ${curPage}">添加一位新学生</a>
                <a th:if="${action eq 'tea'}" th:href="'/adm/'+${action}+'/go2Add/'+ ${curPage}">添加一位新教师</a>
            </button>
            <span th:text="${state}" style="color: red;font-size: 20px"/>
            <hr>
            <h4>
                <span th:if="${action eq 'stu'}" >添加学生</span>
                <span th:if="${action eq 'tea'}" >添加教师</span>
            </h4>
            <div>
                <form th:action="'/adm/'+${action}+'/doAdd?curPage='+ ${curPage}" method="post" enctype="multipart/form-data">
                    <table class="table table-hover table-striped table-bordered">
                        <tr>
                            <th style="width: 20%"><p>姓名:</p></th>
                            <td><input type="text" name="uname" th:value="${uname}"></td>
                        </tr>
                        <tr>
                            <th style="width: 20%"><p>电话:</p></th>
                            <td><input type="text" name="phone" th:value="${phone}"></td>
                        </tr>
                        <tr>
                            <th style="width: 20%"><p>密码:</p></th>
                            <td><input type="text" name="pwd" th:value="${pwd}"></td>
                        </tr>
                        <tr>
                            <th style="width: 20%"><p>照相:</p> </th>
                            <td><input type="file" name="mypic"></td>
                        </tr>
                        <tr th:if="${action eq 'stu'}">
                            <!--难点在下拉框处理, 需要所有班级信息， 并且匹配当前学生所在的班级-->
                            <th style="width: 20%">班级:</th>
                            <td>
                                <select name="clzno" size="1">
                                    <option th:each="c:${clzs}" th:value="${c.clzno}" th:text="${c.clzname}" th:selected="${clzno == c.clzno}"></option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th></th>
                            <td><p>
                                <button class="btn btn-warning" th:if="${action eq 'stu'}">添加学生</button>
                                <button class="btn btn-warning" th:if="${action eq 'tea'}">添加教师</button>
                            </p></td>
                        </tr>

                    </table>


                </form>
            </div>
        </div>

        <div th:if="${date != null}">
            <button class="btn btn-warning">
                <a th:if="${action eq 'stu'}" th:href="'/adm/'+${action}+'/go2Add'">添加一位新学生</a>
                <a th:if="${action eq 'tea'}" th:href="'/adm/'+${action}+'/go2Add/'+ ${curPage}">添加一位新教师</a>
            </button>
            <hr>
            <h4>
                <span th:if="${action eq 'stu'}">修改学生</span>
                <span th:if="${action eq 'tea'}">修改教师</span>
            </h4>
            <div>
                <form th:action="'/adm/'+${action}+'/'+${date}+'?curPage='+ ${curPage}" method="post" enctype="multipart/form-data">
                    <table class="table table-hover table-striped table-bordered" style="text-align: center">
                        <tr th:if="${uid != null}">
                            <th style="width: 20%"><p>编号:</p></th>
                            <td><input type="text" name="uid"  th:value="${uid}" th:readonly="true"></td>
                        </tr>
                        <tr>
                            <th style="width: 20%"><p>名称:</p></th>
                            <td><input type="text" name="uname" th:value="${uname}"></td>
                        </tr>
                        <tr>
                            <th style="width: 20%"><p>电话:</p></th>
                            <td><input type="text" name="phone" th:value="${phone}"></td>
                        </tr>
                        <tr>
                            <th style="width: 20%"><p>密码:</p></th>
                            <td><input type="text" name="pwd" th:value="${pwd}"></td>
                        </tr>
                        <tr>
                            <th style="width: 20%"><p>当前头像</p></th>
                            <td><img  th:src="'/adm/'+${action}+'/showimg/'+${pic}" style="width: 25%;height: 25%"/></td>
                        </tr>
                        <tr>
                            <th style="width: 20%"><p>图片:</p></th>
                            <td><input type="file" name="mypic"></td>
                        </tr>
                        <tr th:if="${action eq 'stu'}">
                            <!--难点在下拉框处理, 需要所有班级信息， 并且匹配当前学生所在的班级-->
                            <th style="width: 20%"><p>班级:</p></th>
                            <td><select name="clzno" size="1"><option th:each="c:${clzs}" th:value="${c.clzno}" th:text="${c.clzname}" th:selected="${clzno == c.clzno}"></option></select></td>
                        </tr>
                        <tr>
                            <th style="width: 20%"></th>
                            <td><button th:if="${action eq 'stu'}" class="btn btn-warning">修改学生</button>
                                <button th:if="${action eq 'tea'}" class="btn btn-warning">修改教师</button></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>




    </div>
</div>
</body>
</html>